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

feat(otelgin): enhance gin error tracking with span recording #6346

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

flc1125
Copy link

@flc1125 flc1125 commented Nov 19, 2024

No description provided.

@flc1125 flc1125 requested a review from a team as a code owner November 19, 2024 16:10
@dmathieu
Copy link
Member

Could you test this change?
By checking there's indeed an error here for example: https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/instrumentation/github.com/gin-gonic/gin/otelgin/test/gintrace_test.go#L123

Also, I wonder if we need to keep the gin.errors attribute. While removing it is a breaking change, keeping it is redundant.

@dmathieu
Copy link
Member

Side note that otelgin has no owner, so it may be removed soon.
#6190

@flc1125
Copy link
Author

flc1125 commented Nov 20, 2024

Side note that otelgin has no owner, so it may be removed soon. #6190

Okay, will this package still accept new PRs at present?

@dmathieu
Copy link
Member

It does.

Copy link

codecov bot commented Nov 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.9%. Comparing base (73c4165) to head (1fa4d17).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #6346   +/-   ##
=====================================
  Coverage   66.9%   66.9%           
=====================================
  Files        193     193           
  Lines      15652   15653    +1     
=====================================
+ Hits       10479   10480    +1     
  Misses      4882    4882           
  Partials     291     291           
Files with missing lines Coverage Δ
...ation/github.com/gin-gonic/gin/otelgin/gintrace.go 84.2% <100.0%> (+0.1%) ⬆️
---- 🚨 Try these New Features:

@flc1125
Copy link
Author

flc1125 commented Nov 20, 2024

#6190

I think I can give it a try.

If I come to maintain it, what do I need to do?

@dmathieu
Copy link
Member

That's documented in the issue, as well as in https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/CONTRIBUTING.md#code-owners.

CHANGELOG.md Outdated Show resolved Hide resolved
@flc1125
Copy link
Author

flc1125 commented Nov 21, 2024

Could you test this change? By checking there's indeed an error here for example: main/instrumentation/github.com/gin-gonic/gin/otelgin/test/gintrace_test.go#L123

Also, I wonder if we need to keep the gin.errors attribute. While removing it is a breaking change, keeping it is redundant.

It's done.

@flc1125
Copy link
Author

flc1125 commented Nov 21, 2024

Side note that otelgin has no owner, so it may be removed soon.

I spent some time reading through the requirements. I understand that I may still need to make some contributions before applying. If so, I need some time.

.golangci.yml Outdated Show resolved Hide resolved
@flc1125
Copy link
Author

flc1125 commented Nov 21, 2024

link: #5252

@dmathieu dmathieu dismissed their stale review November 21, 2024 13:23

Changes made

Copy link
Member

@dmathieu dmathieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is starting to look good 😸

Copy link
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just nit comments. Can you please address them before we merge?

@@ -13,6 +13,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Added support for providing `endpoint`, `pollingIntervalMs` and `initialSamplingRate` using environment variable `OTEL_TRACES_SAMPLER_ARG` in `go.opentelemetry.io/contrib/samples/jaegerremote`. (#6310)
- Added support exporting logs via OTLP over gRPC in `go.opentelemetry.io/contrib/config`. (#6340)

### Changed

- Record an error instead of setting the `gin.errors` attribute in `go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin`. (#6346)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Record an error instead of setting the `gin.errors` attribute in `go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin`. (#6346)
- Record errors instead of setting the `gin.errors` attribute in `go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin`. (#6346)

"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/propagation"
semconv "go.opentelemetry.io/otel/semconv/v1.20.0"
oteltrace "go.opentelemetry.io/otel/trace"

"go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin/internal/semconvutil"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you revert this import rearrange change? We are grouping go.openteletry.io. See

goimports:
local-prefixes: go.opentelemetry.io

oteltrace "go.opentelemetry.io/otel/trace"

"go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you revert this import rearrange change? We are grouping go.openteletry.io. See

goimports:
local-prefixes: go.opentelemetry.io

@@ -120,7 +122,17 @@ func TestError(t *testing.T) {
attr := span.Attributes()
assert.Contains(t, attr, attribute.String("net.host.name", "foobar"))
assert.Contains(t, attr, attribute.Int("http.status_code", http.StatusInternalServerError))
assert.Contains(t, attr, attribute.String("gin.errors", "Error #01: oh no\n"))

// verify the error event
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// verify the error event
// verify the error events

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants