Skip to content

Commit

Permalink
Continue to work on setting appropriate attributes
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph Woodward <joseph.woodward@xeuse.com>
  • Loading branch information
josephwoodward committed Oct 26, 2022
1 parent f414288 commit e390757
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions client/opentelemetry.go
Expand Up @@ -65,7 +65,7 @@ func (t *openTelemetryTransport) Submit(op *runtime.ClientOperation) (interface{
return submit, err
}

func createOpenTelemetryClientSpan(op *runtime.ClientOperation, _ http.Header, _ string, opts []trace.SpanStartOption) trace.Span {
func createOpenTelemetryClientSpan(op *runtime.ClientOperation, _ http.Header, host string, opts []trace.SpanStartOption) trace.Span {
ctx := op.Context
span := trace.SpanFromContext(ctx)

Expand All @@ -77,11 +77,13 @@ func createOpenTelemetryClientSpan(op *runtime.ClientOperation, _ http.Header, _
op.Context = ctx

span.SetAttributes(
attribute.String("net.peer.name", host),
// attribute.String("net.peer.port", ""),
attribute.String(string(semconv.HTTPRouteKey), op.PathPattern),
attribute.String(string(semconv.HTTPMethodKey), op.Method),
attribute.String("span.kind", trace.SpanKindClient.String()),
//TODO: Get scheme reliably from header
attribute.String("http.scheme", "https"),
//TODO: Figure out the best way to get the scheme?
attribute.String("http.scheme", op.Schemes[0]),
)

return span
Expand Down
2 changes: 1 addition & 1 deletion client/opentelemetry_test.go
Expand Up @@ -86,12 +86,12 @@ func assertOpenTelemetrySubmit(t *testing.T, operation *runtime.ClientOperation,
assert.Equal(t, span.Status.Code, codes.Error)
assert.Equal(t, []attribute.KeyValue{
// "component": "go-openapi",
attribute.String("net.peer.name", "remote_host"),
attribute.String("http.route", "/kubernetes-clusters/{cluster_id}"),
attribute.String("http.method", "GET"),
attribute.String("span.kind", trace.SpanKindClient.String()),
attribute.String("http.scheme", "https"),
attribute.Int("http.status_code", 490),
// "peer.hostname": "remote_host",
// "peer.service": "service",
// "error": true,
}, span.Attributes)
Expand Down

0 comments on commit e390757

Please sign in to comment.