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(bunotel): Ability to override span names #1120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

NathanBaulch
Copy link
Contributor

@NathanBaulch NathanBaulch commented Feb 8, 2025

Bun OTEL spans would be much more informative in APM tools if their name included the primary table being queried. This could be added easily enough, however it might be nice to follow the convention used in other popular middlewares like otelhttp by adding a WithSpanNameFormatter option.

This PR allows me to add the primary query table to span names like so:

bunotel.NewQueryHook(bunotel.WithSpanNameFormatter(func(event *bun.QueryEvent) string {
	name := event.Operation()
	if event.IQuery != nil {
		if tableName := event.IQuery.GetTableName(); tableName != "" {
			name += " " + tableName
		}
	}
	return name
}))

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.

1 participant