Skip to content

Commit 321640e

Browse files
committedApr 17, 2019
Examples: Minor tweaks and improvements
1 parent cf37baf commit 321640e

File tree

7 files changed

+21
-13
lines changed

7 files changed

+21
-13
lines changed
 

‎_examples/cloudfunction/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ Invoke your function over HTTP:
2323
$ curl https://...cloudfunctions.net/clusterstatus
2424
```
2525

26-
See the **[`function.go`](./function.go)** file for implementation.
26+
See the **[`function.go`](./function.go)** file for implementation and the **[`function_test.go`](./function_test.go)** file for the example of implementing a mock transport for testing.

‎_examples/customization.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
// CountingTransport adds a custom header to the request, logs the information about
2222
// the request and response, and counts the number of requests to the client.
2323
//
24-
// Since it implements the `http.RoundTripper` interface, so it can be passed
24+
// Since it implements the `http.RoundTripper` interface, it can be passed
2525
// to the client as a custom HTTP transport implementation.
2626
//
2727
type CountingTransport struct {
@@ -57,8 +57,12 @@ func (t *CountingTransport) RoundTrip(req *http.Request) (*http.Response, error)
5757
func main() {
5858
var wg sync.WaitGroup
5959

60+
// Create the custom transport.
61+
//
6062
tp := CountingTransport{}
6163

64+
// Pass the custom transport to the client.
65+
//
6266
es, _ := elasticsearch.NewClient(
6367
elasticsearch.Config{Transport: &tp},
6468
)

‎_examples/encoding/Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ test: clean setup ## Run tests
44
go run gjson.go
55
go run easyjson.go
66

7+
bench: clean setup # Run benchmarks
8+
go test -run=none -bench=. -benchmem benchmark_test.go
9+
710
setup: ## Install & Setup
811
@go get -u github.com/mailru/easyjson/...
912
go generate ./model
1013

1114
clean: ## Remove artifacts
1215
@rm -f model/*_easyjson.go
1316

14-
bench: # Run benchmarks
15-
go test -run=none -bench=. -benchmem benchmark_test.go
16-
17-
.PHONY: clean setup test
17+
.PHONY: clean bench setup test

‎_examples/instrumentation/Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# $ docker build --tag elastic/go-elasticsearch-demo-instrumentation .
22
# $ docker run -it --network instrumentation_elasticstack --rm elastic/go-elasticsearch-demo-instrumentation
33
#
4-
FROM golang:1.11-alpine
4+
FROM golang:1-alpine
55

66
RUN apk add --no-cache --quiet gcc g++ ca-certificates make curl git jq
77

88
WORKDIR /go-elasticsearch-demo-instrumentation
99

10-
COPY ./go.mod ./
10+
COPY go.mod .
1111
RUN go mod download
1212

1313
ENV TERM xterm-256color
@@ -20,6 +20,6 @@ ENV ELASTIC_APM_METRICS_INTERVAL=5s
2020
ENV ELASTIC_APM_LOG_FILE=stderr
2121
ENV ELASTIC_APM_LOG_LEVEL=debug
2222

23-
COPY ./apmelasticsearch.go ./opencensus.go ./
23+
COPY apmelasticsearch.go opencensus.go ./
2424

2525
CMD go run apmelasticsearch.go

‎_examples/instrumentation/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ The [**`apmelasticsearch.go`**](./apmelasticsearch.go) example demonstrates inst
1717
Run the example interactively with Docker and inspect the UI in <a href="http://localhost:5601/app/apm#/go-elasticsearch-demo-instrumentation/transactions?_g=(time:(from:now-15m,to:now))">Kibana</a>:
1818

1919
docker-compose --file elasticstack.yml up --build
20+
21+
To destroy the Docker assets for the example, run:
22+
23+
docker-compose --file elasticstack.yml down --remove-orphans --volumes

‎_examples/instrumentation/elasticstack.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ services:
1616

1717
# --- Elasticsearch ---------------------------------------------------------
1818
elasticsearch:
19-
image: docker.elastic.co/elasticsearch/elasticsearch:${VERSION:-7.0.0-beta1}
19+
image: docker.elastic.co/elasticsearch/elasticsearch:${VERSION:-7.0.0}
2020
container_name: elasticsearch
2121
volumes:
2222
- es_data:/usr/share/elasticsearch/data:delegated
@@ -39,7 +39,7 @@ services:
3939

4040
# --- Kibana ----------------------------------------------------------------
4141
kibana:
42-
image: docker.elastic.co/kibana/kibana:${VERSION:-7.0.0-beta1}
42+
image: docker.elastic.co/kibana/kibana:${VERSION:-7.0.0}
4343
container_name: kibana
4444
networks: ['elasticstack']
4545
environment:
@@ -52,7 +52,7 @@ services:
5252

5353
# --- APM Server ------------------------------------------------------------
5454
apm-server:
55-
image: docker.elastic.co/apm/apm-server:${VERSION:-7.0.0-beta1}
55+
image: docker.elastic.co/apm/apm-server:${VERSION:-7.0.0}
5656
container_name: apm_server
5757
networks: ['elasticstack']
5858
command: >

‎_examples/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func main() {
114114
if res.IsError() {
115115
var e map[string]interface{}
116116
if err := json.NewDecoder(res.Body).Decode(&e); err != nil {
117-
log.Fatalf("error parsing the response body: %s", err)
117+
log.Fatalf("Error parsing the response body: %s", err)
118118
} else {
119119
// Print the response status and error information.
120120
log.Fatalf("[%s] %s: %s",

0 commit comments

Comments
 (0)