{"id":20337326,"url":"https://github.com/expediadotcom/haystack-blob-example","last_synced_at":"2025-07-26T16:41:04.808Z","repository":{"id":87471426,"uuid":"193479314","full_name":"ExpediaDotCom/haystack-blob-example","owner":"ExpediaDotCom","description":"Example application to show how blobs and spans interact with haystack environment","archived":false,"fork":false,"pushed_at":"2022-05-20T21:01:23.000Z","size":40,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-14T17:30:38.866Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-24T09:54:28.000Z","updated_at":"2021-02-24T01:27:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"8ef91a3a-04e2-410a-a6cd-881bcc961079","html_url":"https://github.com/ExpediaDotCom/haystack-blob-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpediaDotCom%2Fhaystack-blob-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpediaDotCom%2Fhaystack-blob-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpediaDotCom%2Fhaystack-blob-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpediaDotCom%2Fhaystack-blob-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ExpediaDotCom","download_url":"https://codeload.github.com/ExpediaDotCom/haystack-blob-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241860013,"owners_count":20032318,"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","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:39.110Z","updated_at":"2025-03-04T13:46:55.336Z","avatar_url":"https://github.com/ExpediaDotCom.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Haystack Blob Example\n\nThis application demonstrates the use of Spans and Blobs together to be used by [Haystack-Agent](https://github.com/ExpediaDotCom/haystack-agent). This will show how the metadata for a blob stored could be saved as a tag in a span to be used later for reading them again.\n\nIn this example, the client sends a request to the server which then sends the response back to it. Both the request and response are saved as a blob at the client side and then their key is added to the span as a tag. This tag can be further used by haystack to retrieve the blob.\n\n## Understanding the implementation\nTo understand how span tracing works and is implemented please refer [haystack-dropwizard-example](https://github.com/ExpediaDotCom/haystack-dropwizard-example).\nFor adding the request/response blobs along with tracing, you follow the same steps as tracing example, additionally you need to provide blob configuration similar to:\n\n```yaml\n\nblobs:\n  enabled: true\n  store:\n   name: file\n```\nAnd update AppConfiguration to return the [BlobFactory](https://github.com/ExpediaDotCom/haystack-blob-example/blob/master/src/main/java/com/expedia/www/haystack/dropwizard/example/config/AppConfiguration.java#L22) instance.\n\n#### How to blob conditionally?\nThere may be a valid usecase where you don't want to blob request/response with every span, may be for performance reasons.\nBut you may want to turn on the blobs only if you see a X-DEBUG header from your upstream request. In order to do this, \nyou can implement these functions and setBlobable in BlobFactory. By default, they are set to true.\n\n```java\n    boolean isServerRequestValidForBlob(ContainerRequestContext req);\n    boolean isServerResponseValidForBlob(ContainerResponseContext resp);\n    boolean isClientRequestValidForBlob(ClientRequestContext req);\n    boolean isClientResponseValidForBlob(ClientResponseContext resp);\n```\n\n## Dependencies involved\n\nWe use [haystack-dropwizard](https://github.com/ExpediaDotCom/haystack-dropwizard) library version \u003e= 0.3.1 that does all the heavy lifting for adding the support of blob feature.\n \n ## Running this example\n  \n #### Build\n \n Required:\n *  Java 1.8\n \n  Build:\n\n```mvn clean package```\n \n#### Run locally without haystack-agent (Just for debugging purpose)\n * Run the client on [localhost:9091](http://localhost:9091)\n\n    ```java -jar target/haystack-blob-example-service-1.0-SNAPSHOT.jar client config-client-local.yaml```\n\n * Run the server on [localhost:9090](http://localhost:9090)\n\n    ```java -jar target/haystack-blob-example-service-1.0-SNAPSHOT.jar server config-server-local.yaml```\n\nThe spans gets logged on the console and blobs will be written under '/blobs' directory in your working directory.\n\n#### Run locally with haystack-agent (mostly for production)\n\n * Run the client on [localhost:9091](http://localhost:9091)\n\n    ```java -jar target/haystack-blob-example-service-1.0-SNAPSHOT.jar client config-client.yaml```\n\n * Run the server on [localhost:9090](http://localhost:9090)\n\n    ```java -jar target/haystack-blob-example-service-1.0-SNAPSHOT.jar server config-server.yaml```\n \n\n#### Test Blob Feature \n  * Send a sample request:\n \n    ```curl http://localhost:9091/message```\n    \nLook for the meta-tags `request-blob` and `response-blob` in the request and response spans respectively.\n      \n#### Run locally with haystack server intact \n\nTo run the complete example properly please refer steps given in [haystack-docker](https://github.com/ExpediaDotCom/haystack-docker) for [spans-and-blobs](https://github.com/ExpediaDotCom/haystack-docker/tree/master/example). This will also start [haystack-agent](https://github.com/ExpediaDotCom/haystack-agent) at port `35001` and [haystack-ui](https://github.com/ExpediaDotCom/haystack-ui) at port `8080` locally along with the http [reverse-proxy](https://github.com/ExpediaDotCom/blobs/tree/master/haystack-blobs) at port `35002` for grpc service.\n\nAfter running the docker you can test the usage by following the given steps:\n\n * Send a sample request:\n \n    ```curl http://localhost:9091/message```\n    \n    One can also use the sample script we have to send more requests to the server application and see metrics such as count, duration histogram etc in Haystack UI under trends.\n    ```\n    ./run.sh\n    ```\n    \n * Open Haystack UI at http://localhost:8080/ and search for `serviceName=blob-client` to see the traces.\n\n* Open the trace and look for `request-blob` and `response-blob` tags.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexpediadotcom%2Fhaystack-blob-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexpediadotcom%2Fhaystack-blob-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexpediadotcom%2Fhaystack-blob-example/lists"}