Skip to content

otelaws s3 error responses should not always be recorded #6331

Open
@sjones4

Description

@sjones4

Description

Instrumentation for s3 records 3xx http responses as errors.

https://github.com/open-telemetry/opentelemetry-go-contrib/blob/11cf0df7388a/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/aws.go#L75-L79

There is already http.status_code that covers the result of the call, so recording the error does not add any useful information.

When getting objects from s3 conditionally a 3xx http response is expected if the condition is not satisfied. For example, you might get an object if is has been modified since the last time it was accessed.

Environment

  • OS: Linux
  • Architecture: x86
  • Go Version: 1.23.2
  • otelaws version: v0.52.0

Steps To Reproduce

s3Client.GetObject(ctx, &s3.GetObjectInput{
		Bucket:          aws.String(bucket),
		Key:             aws.String(object),
		IfModifiedSince: lastModified,
	})

Expected behavior

Don't record an error for 3xx responses.

Potential fix

The error could be checked using something like:

import (
	"net/http"
	awshttp "github.com/aws/aws-sdk-go-v2/aws/transport/http"

...

	var respErr *awshttp.ResponseError
	if errors.As(err, &respErr) && respErr.HTTPStatusCode() == http.StatusNotModified {

It seems reasonable to do this for all services, or there could be an "IsTraceableError" check for each service which would not record these "error" responses.

I can create a PR for this if useful.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Needs triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions