{"id":20337342,"url":"https://github.com/expediadotcom/haystack-opentelemetry-example","last_synced_at":"2026-04-24T05:31:30.325Z","repository":{"id":39935214,"uuid":"265024269","full_name":"ExpediaDotCom/haystack-opentelemetry-example","owner":"ExpediaDotCom","description":null,"archived":false,"fork":false,"pushed_at":"2022-05-20T21:44:39.000Z","size":81,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-04T13:47:20.899Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ExpediaDotCom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-18T18:19:35.000Z","updated_at":"2020-06-13T01:33:05.000Z","dependencies_parsed_at":"2022-09-13T20:41:54.322Z","dependency_job_id":null,"html_url":"https://github.com/ExpediaDotCom/haystack-opentelemetry-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ExpediaDotCom/haystack-opentelemetry-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpediaDotCom%2Fhaystack-opentelemetry-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpediaDotCom%2Fhaystack-opentelemetry-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpediaDotCom%2Fhaystack-opentelemetry-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpediaDotCom%2Fhaystack-opentelemetry-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ExpediaDotCom","download_url":"https://codeload.github.com/ExpediaDotCom/haystack-opentelemetry-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpediaDotCom%2Fhaystack-opentelemetry-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27471890,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-03T02:00:06.367Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T21:08:43.097Z","updated_at":"2025-12-03T08:06:02.627Z","avatar_url":"https://github.com/ExpediaDotCom.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Haystack OpenTelemetry through Zipkin\n\n[![Build Status](https://travis-ci.org/ExpediaDotCom/haystack-opentelemetry-example.svg?branch=master)](https://travis-ci.org/ExpediaDotCom/haystack-opentelemetry-example)\n[![License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://github.com/ExpediaDotCom/haystack/blob/master/LICENSE)\n\n[OpenTelemetry] provides a single set of APIs, libraries, agents, and collector services to capture distributed traces and metrics from your application. You can analyze them using Prometheus, Jaeger, and other observability tools.\n\nHaystack can consume spans generated from [OpenTelemetry] by using its ZipkinSpanExporter. It currently supports languages such as:\n  - [Java]\n  - [Node.js]\n  - [Python]\n\namong others.\n\n## How to integrate with Haystack\n[Haystack Agent] is capable of consuming Zipkin spans through its [Pitchfork] endpoint. In order to enable this, it needs to be enabled in the configurations files like this:\n```\nagents {\n  spans {\n    ...\n  }\n  ossblobs {\n    ...\n  }\n\n  pitchfork {\n    enabled = true\n    port = 9411\n    http.threads {\n       max = 16\n       min = 2\n    }\n    gzip.enabled = true\n    idle.timeout.ms = 60000\n    stop.timeout.ms = 30000\n    accept.null.timestamps = false\n    max.timestamp.drift.sec = -1\n\n    dispatchers {\n      kafka {\n        bootstrap.servers = \"\u003chost\u003e:19092\"\n        producer.topic = \"proto-spans\"\n        buffer.memory = 1048576\n        retries = 2\n      }\n    }\n  }\n}\n```\n\nAfter this, when agent is initialized it'll listen on http://localhost:9411/api/v1/spans for zipkin spans. Please refer to Haystack Agent documentation for [Pitchfork] endpoint versions.\n\n## Java ZipkinSpanExporter\nThis example will show how to export [OpenTelemetry] spans to haystack through [ZipkinSpanExporter]\n\n### Dependencies\nAdd the appropriate [OpenTelemetry] and Zipkin dependencies:\n```\n    \u003cdependency\u003e\n        \u003cgroupId\u003eio.opentelemetry\u003c/groupId\u003e\n        \u003cartifactId\u003eopentelemetry-api\u003c/artifactId\u003e\n        \u003cversion\u003eLIBRARY_VERSION\u003c/version\u003e\n    \u003c/dependency\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eio.opentelemetry\u003c/groupId\u003e\n        \u003cartifactId\u003eopentelemetry-exporters-zipkin\u003c/artifactId\u003e\n        \u003cversion\u003eLIBRARY_VERSION\u003c/version\u003e\n    \u003c/dependency\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eio.zipkin.zipkin2\u003c/groupId\u003e\n        \u003cartifactId\u003ezipkin\u003c/artifactId\u003e\n        \u003cversion\u003eLIBRARY_VERSION\u003c/version\u003e\n    \u003c/dependency\u003e\n```\n\n### Code Configuration\n\nIn the provided example, a configuration object with the endpoint and service name information is created:\n```\nZipkinExporterConfiguration configuration =\n            ZipkinExporterConfiguration\n                .builder()\n                .setEndpoint(\u003cZIPKIN_ENDPOINT\u003e)\n                .setServiceName(\u003cSERVICE_NAME\u003e)\n                .setEncoder(SpanBytesEncoder.JSON_V2) // JSON_V1, PROTO3 or THRIFT\n                .build();\n```\n\nAfter creating the configuration object, a ZipkinSpanExporter is created, this will be the object\nthat will actually send our spans:\n```\n ZipkinSpanExporter exporter = ZipkinSpanExporter.create(configuration);\n```\n\nOnce the exporter object is set up, the spans are created by using the SpanData class \nwhich zipkin consumes:\n```\nSpanData spandata = SpanData.newBuilder()\n                    .setTraceId(...)\n                    .setName(...)\n                    .setSpanId(...)\n                    .setStartEpochNanos(...)\n                    .setEndEpochNanos(...)\n                    .setHasEnded(...)\n                    .setHasRemoteParent(...)\n                    .setKind(...)\n                    .setStatus(...)\n                    .setAttributes(...)\n                    .setTotalAttributeCount(...)\n                    .build();\n```\n\nAfter the span(s) are created, the method export from the previously created exporter is used to send the spans: \n```\nexporter.export(Arrays.asList(spandata));\n```\n\nSince this has configured the Haystack [Pitchfork] endpoint it'll send the spans there for \nconsumption. [Haystack Agent] understands Zipkin spans and parses them into our own spans and \nprocess them into our pipeline.\n\n[//]: # (These are reference links used in the body of this note and get stripped out when the markdown processor does its job. There is no need to format nicely because it shouldn't be seen. Thanks SO - http://stackoverflow.com/questions/4823468/store-comments-in-markdown-syntax)\n\n   [Java]: https://github.com/open-telemetry/opentelemetry-java/blob/d7f6d5a64176b44752bbd4bd403716a0f150b3e6/exporters/zipkin/src/main/java/io/opentelemetry/exporters/zipkin/ZipkinSpanExporter.java\n   [Node.js]:https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-exporter-zipkin\n   [Python]:https://opentelemetry-python.readthedocs.io/en/latest/ext/zipkin/zipkin.html\n   [OpenTelemetry]: https://opentelemetry.io/\n   [Pitchfork]: https://github.com/ExpediaDotCom/haystack-agent#zipkin-agent-pitchfork\n   [Haystack Agent]: https://github.com/ExpediaDotCom/haystack-agent\n   \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexpediadotcom%2Fhaystack-opentelemetry-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexpediadotcom%2Fhaystack-opentelemetry-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexpediadotcom%2Fhaystack-opentelemetry-example/lists"}