Skip to content
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

fix aws sdk span name #3582

Merged
merged 9 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

- Add the new `go.opentelemetry.io/contrib/instrgen` package to provide auto-generated source code instrumentation. (#3068)

### Fixed

- Fix aws sdk span name
nemoshlag marked this conversation as resolved.
Show resolved Hide resolved
([#3582](https://github.com/open-telemetry/opentelemetry-go-contrib/issues/3521))

## [1.16.0-rc.1/0.41.0-rc.1/0.9.0-rc.1] - 2023-03-02

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func (m otelMiddlewares) initializeMiddlewareAfter(stack *middleware.Stack) erro
ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
out middleware.InitializeOutput, metadata middleware.Metadata, err error) {
serviceID := v2Middleware.GetServiceID(ctx)
operation := v2Middleware.GetOperationName(ctx)
MrAlias marked this conversation as resolved.
Show resolved Hide resolved

attributes := []attribute.KeyValue{
ServiceAttr(serviceID),
Expand All @@ -70,7 +71,7 @@ func (m otelMiddlewares) initializeMiddlewareAfter(stack *middleware.Stack) erro
attributes = append(attributes, setter(ctx, in)...)
}

ctx, span := m.tracer.Start(ctx, serviceID,
ctx, span := m.tracer.Start(ctx, serviceID+"."+operation,
trace.WithTimestamp(ctx.Value(spanTimestampKey{}).(time.Time)),
trace.WithSpanKind(trace.SpanKindClient),
trace.WithAttributes(attributes...),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func TestAppendMiddlewares(t *testing.T) {
require.Len(t, spans, 1)
span := spans[0]

assert.Equal(t, "Route 53", span.Name())
assert.Equal(t, "Route 53.ChangeResourceRecordSets", span.Name())
assert.Equal(t, trace.SpanKindClient, span.SpanKind())
assert.Equal(t, c.expectedError, span.Status().Code)
attrs := span.Attributes()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestDynamodbTags(t *testing.T) {
require.Len(t, spans, 1)
span := spans[0]

assert.Equal(t, "DynamoDB", span.Name())
assert.Equal(t, "DynamoDB.GetItem", span.Name())
assert.Equal(t, trace.SpanKindClient, span.SpanKind())
attrs := span.Attributes()
assert.Contains(t, attrs, attribute.Int("http.status_code", cases.expectedStatusCode))
Expand Down Expand Up @@ -182,7 +182,7 @@ func TestDynamodbTagsCustomSetter(t *testing.T) {
require.Len(t, spans, 1)
span := spans[0]

assert.Equal(t, "DynamoDB", span.Name())
assert.Equal(t, "DynamoDB.GetItem", span.Name())
assert.Equal(t, trace.SpanKindClient, span.SpanKind())
attrs := span.Attributes()
assert.Contains(t, attrs, attribute.Int("http.status_code", cases.expectedStatusCode))
Expand Down