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

go: go.opentelemetry.io/otel/semconv@v1.26.0: reading go.opentelemetry.io/otel/semconv/go.mod at revision semconv/v1.26.0: unknown revision semconv/v1.26.0 #5372

Closed
mehulparmariitr opened this issue May 17, 2024 · 8 comments
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@mehulparmariitr
Copy link

mehulparmariitr commented May 17, 2024

Description

A clear and concise description of what the bug is.

go: go.opentelemetry.io/otel/semconv@v1.26.0: reading go.opentelemetry.io/otel/semconv/go.mod at revision semconv/v1.26.0: unknown revision semconv/v1.26.0

Environment

  • OS: macos
  • Architecture: ARM64
  • Go Version: GOVERSION='go1.21.10'
  • opentelemetry-go version: v1.26.0

Steps To Reproduce

go mod tidy is not working with go.opentelemetry.io/otel/semconv/v1.26.0

Only 1.24.0 I am able to fetch

Expected behavior

Go get should work

@mehulparmariitr mehulparmariitr added the bug Something isn't working label May 17, 2024
@pellared
Copy link
Member

The latest semantic conventions version is v1.25.0. See: https://github.com/open-telemetry/semantic-conventions/releases/tag/v1.25.0.

You should use go.opentelemetry.io/otel/semconv/v1.25.0

@pellared pellared closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2024
@pellared pellared added the invalid This doesn't seem right label May 17, 2024
@mehulparmariitr
Copy link
Author

mehulparmariitr commented May 17, 2024

The latest semantic conventions version is v1.25.0. See: https://github.com/open-telemetry/semantic-conventions/releases/tag/v1.25.0.

You should use go.opentelemetry.io/otel/semconv/v1.25.0

panic: conflicting Schema URL: https://opentelemetry.io/schemas/1.24.0 and https://opentelemetry.io/schemas/1.25.0

I am using 1.25.0 But getting this error. From where 1.24.0 is coming?

image

Why resource.default() still pointing to 1.24.0?

@mehulparmariitr
Copy link
Author

I am not able to get any output on OtelCollector logs. These are my configurations -

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318
processors:
  batch:

exporters:
  debug:
    verbosity: detailed

extensions:
  health_check:
  pprof:
  zpages:

service:
  extensions: [health_check, pprof, zpages]
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [batch]
      exporters: [debug]
version: '3'
services: 
  otel-collector:
    image: otel/opentelemetry-collector-contrib
    volumes:
      - './otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml'
    ports:
      - '1888:1888'
      - '8888:8888'
      - '8889:8889'
      - '13133:13133'
      - '4317:4317'
      - '30706:4318'
      - '55679:55679'

My Otel config class -

package metrics

import (
	"context"
	semconv "go.opentelemetry.io/otel/semconv/v1.25.0"
	"log"
	"time"

	"go.opentelemetry.io/otel"
	"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp"
	"go.opentelemetry.io/otel/sdk/metric"
	"go.opentelemetry.io/otel/sdk/resource"
)

func CreateMeterProvider() {
	// Create resource.
	res, err := newResource()
	if err != nil {
		panic(err)
	}

	// Create a meter provider.
	// You can pass this instance directly to your instrumented code if it
	// accepts a MeterProvider instance.
	meterProvider, err := newMeterProvider(res)
	if err != nil {
		panic(err)
	}

	// Handle shutdown properly so nothing leaks.
	defer func() {
		if err := meterProvider.Shutdown(context.Background()); err != nil {
			log.Println(err)
		}
	}()

	// Register as global meter provider so that it can be used via otel.Meter
	// and accessed using otel.GetMeterProvider.
	// Most instrumentation libraries use the global meter provider as default.
	// If the global meter provider is not set then a no-op implementation
	// is used, which fails to generate data.
	otel.SetMeterProvider(meterProvider)
}

func newResource() (*resource.Resource, error) {
	return resource.NewWithAttributes(semconv.SchemaURL,
		semconv.ServiceName("otel-Service"),
		semconv.ServiceVersion("0.1.0"),
	), nil
}

func newMeterProvider(res *resource.Resource) (*metric.MeterProvider, error) {
	metricExporter, err := otlpmetrichttp.New(
		context.Background(),
		otlpmetrichttp.WithEndpoint("0.0.0.0:30706"), // Collector's HTTP metric endpoint
		otlpmetrichttp.WithInsecure(),                // Disable TLS for local dev (use HTTPS in production!)
	)
	if err != nil {
		return nil, err
	}

	meterProvider := metric.NewMeterProvider(
		metric.WithResource(res),
		metric.WithReader(metric.NewPeriodicReader(metricExporter,
			// Default is 1m. Set to 3s for demonstrative purposes.
			metric.WithInterval(3*time.Second))),
	)
	return meterProvider, nil
}

How I am using it in a separate class

var (
	meter          metric.Meter
	requestCount   metric.Int64Counter
	requestDur     metric.Float64Histogram
	err            error
)

func InitSignalFx() {
	
	CreateMeterProvider()
	meter = otel.Meter("abc.sdlc")
	requestCount, err = meter.Int64Counter(
		"api.counter",
		metric.WithDescription("Number of API calls."),
	)

	if err != nil {
		panic(err)
	}

	requestCount.Add(context.Background(), 1)
	requestDur, err = meter.Float64Histogram(
		"task.duration",
		metric.WithDescription("The duration of task execution."),
	)
	if err != nil {
		panic(err)
	}
}

Can you help @pellared

@pellared
Copy link
Member

pellared commented May 17, 2024

I created #5373.
Before this is solved (and released) I suggest using go.opentelemetry.io/otel/semconv/v1.24.0 instead.

Sorry for inconvenience.

@mehulparmariitr
Copy link
Author

mehulparmariitr commented May 17, 2024

No issues @pellared . Can you look at my configuration, what is wrong? Why no metrics logs in otel Collector?

@pellared
Copy link
Member

CreateMeterProvider calls meterProvider.Shutdown. Look at https://opentelemetry.io/docs/languages/go/getting-started/#initialize-the-opentelemetry-sdk to see how you can properly make sure that Shutdown is called just before the application closes.

@mehulparmariitr
Copy link
Author

@pellared Thanks for the help its working fine now! I am also seeing metrics in Otel collector from tests ran by otel library in golang code. How to disable watching them. As I am interested in my own metrics only.

Metric #4
otel-collector-1  | Descriptor:
otel-collector-1  |      -> Name: rpc.client.responses_per_rpc
otel-collector-1  |      -> Description: Measures the number of messages received per RPC. Should be 1 for all non-streaming RPCs.
otel-collector-1  |      -> Unit: {count}
otel-collector-1  |      -> DataType: Histogram
otel-collector-1  |      -> AggregationTemporality: Cumulative
otel-collector-1  | HistogramDataPoints #0
otel-collector-1  | Data point attributes:
otel-collector-1  |      -> rpc.grpc.status_code: Int(0)
otel-collector-1  |      -> rpc.method: Str(WriteLogEntries)
otel-collector-1  |      -> rpc.service: Str(google.logging.v2.LoggingServiceV2)
otel-collector-1  |      -> rpc.system: Str(grpc)

@pellared
Copy link
Member

I am locking this conversation as it becomes more and more off-topic.

@open-telemetry open-telemetry locked as resolved and limited conversation to collaborators May 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants