-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update go-client - new telemetry #1330
Conversation
4b5a704
to
1e58e20
Compare
249506e
to
e580f87
Compare
dbf5dad
to
b7bf083
Compare
b7bf083
to
cbac529
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
V tomto PR aktualizujem go-client na verziu s telemetriou, a robim nevyhnutne upravy v kode.
go.mod
Outdated
github.com/keboola/go-client v1.14.0 | ||
github.com/keboola/go-client v1.15.1-0.20230522083614-4f425c7ab9ef |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO, upravit verziu podla release, ked sa mergne:
keboola/go-client#95
S3UploadParams: &s3.UploadParams{Path: s3.Path{Key: "foo", Bucket: "bar"}}, | ||
S3UploadParams: &s3.UploadParams{ | ||
Path: s3.Path{Key: "foo", Bucket: "bar"}, | ||
Credentials: s3.Credentials{ | ||
AccessKeyID: "foo", | ||
SecretAccessKey: "bar", | ||
}, | ||
}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Po aktualizacii zavislosti prestal fungovat tento test.
Testuje sa, ze upload na S3 spadne ... no ked nezadam ziadne credentials, tak teraz uz nespadne ako chcem, ale na nejakej validacii, ktora je skor.
grp := client.NewRunGroup(ctx, keboolaProjectAPI.Client()) | ||
grp := request.NewRunGroup(ctx, keboolaProjectAPI.Client()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
V go-client
sa rozdelil client
pkg na: client
a request
, v tomto commite je upraveny kod aby reflektoval tuto zmenu.
// Register legacy OpenCensus metrics, for go-cloud (https://github.com/google/go-cloud/issues/2877) | ||
exporter.RegisterProducer(opencensus.NewMetricProducer()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go-cloud
, ktory pouzivame na pracu s S3/ABS nepodporuje zatial OpenTelemetry, viac v google/go-cloud#2877 (postupne je tych dovodou menej, casom urcite prejdu na OpenTelemetry). Zatial je tu tento bridge.
OpenCensus je zial globalna zalezitost, preto to registrujem na najvyssej moznej urovni, aby to nerozbilo testovatelnost kodu na nizsich urovniach.
httpClient := httpclient.New( | ||
httpclient.WithTelemetry(tel), | ||
httpclient.WithUserAgent(userAgent), | ||
httpclient.WithEnvs(envs), | ||
func(c *httpclient.Config) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
httpclient
je pkg v kac
repe, factory pre go-client
klienta.
Pridavam tu podporu telemetri, ... envs sa nikde uz nepouzivali, tak som ich vyhodil.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Niekedy sme mali envs
na roznych miestach v kode, ... teraz ma kazda service uz svoj config
, ale tu som envs zabudol zmazat.
// Enable telemetry | ||
if conf.telemetry != nil { | ||
cl = cl.WithTelemetry( | ||
conf.telemetry.TracerProvider(), | ||
conf.telemetry.MeterProvider(), | ||
otel.WithRedactedHeaders("X-StorageAPI-Token", "X-KBC-ManageApiToken"), | ||
otel.WithPropagators( | ||
// DataDog supports multiple propagations: tracecontext, B3, legacy DataDog, ... | ||
// W3C tracecontext propagator (propagation.TraceContext{}) is not working with the Storage API dd-trace-php , | ||
// so the B3 propagator is used. | ||
b3.New(b3.WithInjectEncoding(b3.B3MultipleHeader)), | ||
), | ||
) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Namiesto DD telemetrie (low/high) sa pouzije telemetria, ktora je uz v go-client.
Management Token sa nikde nepouziva, nevolame management API, ale dal som ho sem preventivne.
// DDTraceFactory provides TraceFactory for high-level tracing of the API client requests. | ||
func DDTraceFactory() client.TraceFactory { | ||
return func() *client.Trace { | ||
t := &client.Trace{} | ||
|
||
// Api request | ||
var ctx context.Context | ||
var clientRequest client.HTTPRequest // high-level request | ||
var resultType string | ||
|
||
var requestSpan ddtracer.Span | ||
var parsingSpan ddtracer.Span | ||
var retryDelaySpan ddtracer.Span | ||
|
||
t.GotRequest = func(c context.Context, r client.HTTPRequest) context.Context { | ||
clientRequest = r |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stara implementacie DD telemetrie pre httpclient moze ist prec.
Part of: https://keboola.atlassian.net/browse/PSGO-179
Changes:
go-client
.