# serverMap Module data exceptions

**URL:** https://discuss.elastic.co/t/servermap-module-data-exceptions/278012
**Category:** APM
**Tags:** docker, go, server
**Created:** [July 7, 2021, 3:51am UTC](https://discuss.elastic.co/t/servermap-module-data-exceptions/278012 "2021-07-07T03:51:09Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![tttoad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tttoad/32/91162_2.png) [@tttoad](https://discuss.elastic.co/u/tttoad)
#### Post date: [July 7, 2021, 3:51am UTC](https://discuss.elastic.co/t/servermap-module-data-exceptions/278012/1 "2021-07-07T03:51:09Z")

</div>

APM Server version 7.13.2 elasticSearch: 7.13.2 kibana: 7.13.2

The service node of the serverMap module on the Kibana Apm interface cannot be linked up.

1.run apm,es,kibana:

```auto
docker network create -d bridge my-jaeger-net
docker run --name elasticsearch --network=my-jaeger-net -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -d elasticsearch:7.13.2
docker run --name kibana --network=my-jaeger-net -p 5601:5601 -d kibana:7.13.2
docker run -d -p 8200:8200 --name=apm-server --network=my-jaeger-net --user=apm-server elastic/apm-server:7.13.2 --strict.perms=false -e -E output.elasticsearch.hosts=["elasticsearch:9200"]

```

1. run openTelemetry: 0.27.0

```auto
	docker run --name collector --network my-jaeger-net\
  		  -v otelcontribcol_config.yaml:/otelcontribcol_config.yaml \
          -d otel/opentelemetry-collector-contrib:0.27.0 --config=/config.yaml

```

config.yaml:

```auto
receivers:
  jaeger:
    protocols:
      grpc:
        endpoint: 0.0.0.0:14250
exporters:
  logging/detail:
    loglevel: debug
  alibabacloud_logservice/canary:
     / ******* /
  elastic:
    apm_server_url: http://apm-server:8200

service:
  pipelines:
    traces:
      receivers: [jaeger] 
      exporters: [alibabacloud_logservice/canary, elastic]

```

3.run jaeger-agent:

```auto
    docker run -p 6831:6831/udp --network my-jaeger-net -d jaegertracing/jaeger-agent:1.22.0 --reporter.grpc.host-port=collector:14250

```

1. Use uber/jaeger-client-go to send data to jaeger-agent,agent to send data to openTelemetry  
server\_t1:

```auto
package main
import (
	"fmt"
	"io"
	"log"
	"net/http"

	"github.com/opentracing/opentracing-go"
	"github.com/opentracing/opentracing-go/ext"
	"github.com/uber/jaeger-client-go"
	"github.com/uber/jaeger-client-go/config"
)

// service
type service struct {
}

func (m *MySpan) Context() opentracing.SpanContext {
	return m.SpanContext()
}
func (s *service) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
	fmt.Println("request ******")
	tracer := opentracing.GlobalTracer()
	spanCtx, err := tracer.Extract(opentracing.HTTPHeaders, opentracing.HTTPHeadersCarrier(request.Header))
	if err != nil {
		log.Fatal(err)
	}

	span := tracer.StartSpan("service_one_do", ext.RPCServerOption(spanCtx))
	span.Context()
	defer func() {
		span.Finish()
	}()

	writer.Write([]byte("12331"))
}

func main() {
	tracer, closer := initJaeger("service_t2")
	defer closer.Close()

	opentracing.SetGlobalTracer(tracer)
	fmt.Println(http.ListenAndServe(":8083", &service{}))
}

func initJaeger(service string) (opentracing.Tracer, io.Closer) {
	cfg := &config.Configuration{
		Sampler: &config.SamplerConfig{
			Type: "const",
			Param: 1,
		},
		Reporter: &config.ReporterConfig{
			LogSpans: true,
			LocalAgentHostPort: "127.0.0.1:6831",
		},
		ServiceName: service,
	}

	tracer, closer, err := cfg.NewTracer(config.Logger(jaeger.StdLogger))
	if err != nil {
		panic(fmt.Sprintf("ERROR: cannot init Jaeger: %v\n", err))
	}

	return tracer, closer
}

```

server-two:

```auto
package main

import (
	"bytes"
	"fmt"
	"io"
	"log"
	"net/http"

	"github.com/opentracing/opentracing-go"
	"github.com/opentracing/opentracing-go/ext"
	"github.com/uber/jaeger-client-go"
	"github.com/uber/jaeger-client-go/config"
)

func main() {
	tracer, closer := initJaeger("service_t1")

	defer closer.Close()

	opentracing.SetGlobalTracer(tracer)

	do("1")
	// do("2")
}
func do(i string) {
	var url = "http://127.0.0.1:8083"
	tracer := opentracing.GlobalTracer()
	request, err := http.NewRequest(http.MethodGet, url, bytes.NewBuffer([]byte("")))
	if err != nil {
		log.Fatal(err)
	}
	span := tracer.StartSpan("service_two_do" + i)
	defer span.Finish()
	ext.SpanKindRPCClient.Set(span)
	ext.HTTPUrl.Set(span, url)
	ext.HTTPMethod.Set(span, http.MethodGet)

	span.SetTag("traces", "1")
	err = tracer.Inject(span.Context(), opentracing.HTTPHeaders, opentracing.HTTPHeadersCarrier(request.Header))
	if err != nil {
		log.Fatal(err)
	}
	do, err := http.DefaultClient.Do(request)
	if err != nil {
		log.Fatal(err)
	}
	ext.HTTPStatusCode.Set(span, uint16(do.StatusCode))

	all, err := io.ReadAll(do.Body)
	fmt.Println(string(all), err)
}

func initJaeger(service string) (opentracing.Tracer, io.Closer) {
	cfg := &config.Configuration{
		Sampler: &config.SamplerConfig{
			Type: "const",
			Param: 1,
		},
		Reporter: &config.ReporterConfig{
			LogSpans: true,
			LocalAgentHostPort: "127.0.0.1:6831",
		},
		ServiceName: service,
	}

	tracer, closer, err := cfg.NewTracer(config.Logger(jaeger.StdLogger))
	if err != nil {
		panic(fmt.Sprintf("ERROR: cannot init Jaeger: %v\n", err))
	}

	return tracer, closer
}

```

1. The apm interface can view the tracing information normally, but there is no connection information between the services of the serverMap module. The data is reported to AliCloud sls service at the same time, and AliCloud can show the dependency of the service normally.

2. Everything is fine when using go-agent to report data

---

<div class="post-metadata">

### Author: ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)
#### Post date: [July 8, 2021, 2:27am UTC](https://discuss.elastic.co/t/servermap-module-data-exceptions/278012/2 "2021-07-08T02:27:52Z")

</div>

@ttoad welcome to the forum! Thanks for providing all of these details to reproduce the issue, it's really helpful.

The issue here is that Elastic APM and Jaeger have a different data model: Elastic APM has distinct concepts of "transactions" and "spans", whereas Jaeger has only "spans". You can think of a transaction as like an entry-point span -- the first span in a service, for example an incoming HTTP request (like in `service_t2`).

When we translate from Jaeger's data model into Elastic APM's, root Jaeger spans become Elastic APM transactions. For example, the "client span" in `service_t1` becomes a transaction. This is why the service map is not being formed correctly. In Elastic APM, the service map requires destination information that is included only in Elastic APM spans.

To resolve this, you can create an additional Jaeger span in `service_t1`. Something like this:

```auto
tracer := opentracing.GlobalTracer()

// This span becomes an Elastic APM transaction, because it is the trace root.
span := tracer.StartSpan("service_two_do" + i)
defer span.Finish()

var url = "http://127.0.0.1:8083"
request, err := http.NewRequest(http.MethodGet, url, bytes.NewBuffer([]byte("")))
if err != nil {
        log.Fatal(err)
}

// This becomes an Elastic APM span, because it is a child of the above span
// and has the "client" kind. Setting HTTP tags on this span will populate the
// service map and dependency list in the UI.
span = span.Tracer().StartSpan(url, opentracing.ChildOf(span.Context()))
defer span.Finish()
ext.SpanKindRPCClient.Set(span)
ext.HTTPUrl.Set(span, url)
ext.HTTPMethod.Set(span, http.MethodGet)

```

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/6/468769c45aae9704fd317f4d6bb7c8ad487cac6d.png)

---

<div class="post-metadata">

### Author: ![tttoad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tttoad/32/91162_2.png) [@tttoad](https://discuss.elastic.co/u/tttoad)
#### Post date: [July 8, 2021, 2:56am UTC](https://discuss.elastic.co/t/servermap-module-data-exceptions/278012/3 "2021-07-08T02:56:11Z")

</div>

Thank you for your answer, but I want the effect that service\_t1 and service\_t2 are connected, is there any way to do it? Is there a way to modify the openTelemetry or apm to achieve this effect?

---

<div class="post-metadata">

### Author: ![tttoad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tttoad/32/91162_2.png) [@tttoad](https://discuss.elastic.co/u/tttoad)
#### Post date: [July 8, 2021, 3:09am UTC](https://discuss.elastic.co/t/servermap-module-data-exceptions/278012/4 "2021-07-08T03:09:48Z")

</div>

I know what to write, thanks again for your answer.

---

<div class="post-metadata">

### Author: ![cyrilleleclerc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cyrilleleclerc/32/60493_2.png) [@cyrilleleclerc](https://discuss.elastic.co/u/cyrilleleclerc)
#### Post date: [July 12, 2021, 2:01pm UTC](https://discuss.elastic.co/t/servermap-module-data-exceptions/278012/5 "2021-07-12T14:01:39Z")

</div>

Hello @tttoad ,

As discussed on [How does the "jaeger client" data access "APM" via "OpenTelemetry"?](https://discuss.elastic.co/t/how-does-the-jaeger-client-data-access-apm-via-opentelemetry/278375) , I recommend you to use the Elastic OpenTelemetry Protocol native support rather than the OpenTelemetry Collector Exporter for Elastic that has been deprecated few months ago.

See our documentation [OpenTelemetry integration | APM Overview [7.13] | Elastic](https://www.elastic.co/guide/en/apm/get-started/current/open-telemetry-elastic.html) .

The collector configuration will look like:

```auto
receivers:
  jaeger:
    protocols:
      grpc:
        endpoint: 0.0.0.0:14250
exporters:
  logging/detail:
    loglevel: debug
  alibabacloud_logservice/canary:
     / ******* /
  otlp/elastic:
    endpoint: "localhost:8200"
    insecure: true
    headers:
      Authorization: "Bearer my_secret_token"

processors:
  memory_limiter:
    check_interval: 1s
    limit_mib: 2000
  batch:

service:
  pipelines:
    traces:
      receivers: [jaeger] 
      processors: [memory_limiter, batch]
      exporters: [alibabacloud_logservice/canary, otlp/elastic]

```

---

<div class="post-metadata">

### Author: ![tttoad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tttoad/32/91162_2.png) [@tttoad](https://discuss.elastic.co/u/tttoad)
#### Post date: [July 13, 2021, 2:49am UTC](https://discuss.elastic.co/t/servermap-module-data-exceptions/278012/6 "2021-07-13T02:49:06Z")

</div>

![image](https://us1.discourse-cdn.com/elastic/original/3X/9/c/9c26db783dae7c770512693c9012836d9eb30f4b.png)  
I see that the configuration method given in the documentation is still "elastic" instead of "otel/elastic".

---

<div class="post-metadata">

### Author: ![cyrilleleclerc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cyrilleleclerc/32/60493_2.png) [@cyrilleleclerc](https://discuss.elastic.co/u/cyrilleleclerc)
#### Post date: [July 13, 2021, 8:35am UTC](https://discuss.elastic.co/t/servermap-module-data-exceptions/278012/7 "2021-07-13T08:35:35Z")

</div>

Thanks, we will fix this ASAP.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [August 3, 2021, 4:35am UTC](https://discuss.elastic.co/t/servermap-module-data-exceptions/278012/8 "2021-08-03T04:35:49Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
