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(otelhttpclient): move generic otelclient from meteor to salt #16

Merged
merged 11 commits into from
Jun 5, 2024

Conversation

sumslim
Copy link

@sumslim sumslim commented May 30, 2024

Migrating generic otelhttpclient library from meteor to salt, for making it available for other repo to use it and avoid duplication

@sumslim sumslim requested review from haveiss, mabdh and batrov May 30, 2024 08:46
@sumslim sumslim changed the title feat(otelhttpclient): move generic otelhttpclient from meteor to salt feat(otelhttpclient): move generic otelclient from meteor to salt May 30, 2024
go.mod Outdated
go 1.16
go 1.21

toolchain go1.21.8
Copy link
Member

Choose a reason for hiding this comment

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

do we need this?

Copy link
Author

Choose a reason for hiding this comment

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

removed

go.mod Show resolved Hide resolved
attributes []attribute.KeyValue
}

func NewOtelGRPCMonitor(hostName string) Monitor {
Copy link
Member

@mabdh mabdh May 30, 2024

Choose a reason for hiding this comment

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

Suggested change
func NewOtelGRPCMonitor(hostName string) Monitor {
func NewMeter(hostName string, MeterOpts...) Monitor {

We should define a MeterOpts to make it optional to pass meter name so creating a new meter would be

otelgrpc.NewMeter("host", otelgrpc.WithMeterName("github.com/goto/compass"))

Err error
}

type Monitor struct {
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
type Monitor struct {
type Meter struct {

Comment on lines 66 to 67
size := proto.Size(p.(proto.Message))
return size
Copy link
Member

Choose a reason for hiding this comment

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

should we make it safer?

Suggested change
size := proto.Size(p.(proto.Message))
return size
if pm, ok := p.(proto.Message); ok {
return proto.Size(pm)
}
return 0

return size
}

func (m *Monitor) RecordUnary(ctx context.Context, p UnaryParams) {
Copy link
Member

Choose a reason for hiding this comment

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

if we don't use this outside, make it private

Suggested change
func (m *Monitor) RecordUnary(ctx context.Context, p UnaryParams) {
func (m *Monitor) recordUnary(ctx context.Context, p UnaryParams) {

Copy link
Author

Choose a reason for hiding this comment

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

existing unit test call

"testing"
"time"

pb "github.com/goto/optimus/protos/gotocompany/optimus/core/v1beta1"
Copy link
Member

Choose a reason for hiding this comment

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

should use sample proto/server for this

commonv1 "github.com/goto/salt/server/example/proto/gotocompany/common/v1"

}

func NewMeter(hostName string, meterOpts ...MeterOpts) Meter {
meter := otel.Meter("github.com/goto/salt/telemetry/otelgrpc")
Copy link
Member

Choose a reason for hiding this comment

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

The name should not be fixed like this. The one that uses library should be able to configure this

@sumslim sumslim merged commit fac8486 into main Jun 5, 2024
3 checks passed
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