Skip to content

Adds openapi spec for POST /api/v2/spans including the json format#33

Merged
codefromthecrypt merged 1 commit intomasterfrom
v2
Aug 15, 2017
Merged

Adds openapi spec for POST /api/v2/spans including the json format#33
codefromthecrypt merged 1 commit intomasterfrom
v2

Conversation

@codefromthecrypt
Copy link
Member

@codefromthecrypt codefromthecrypt commented Aug 14, 2017

See openzipkin/zipkin#1499 for the description of this format

I tested this with a deviation of @devinsba example here: openzipkin/zipkin-api-example#1

package main

import (
	"fmt"
	"log"
	"math/rand"
	"strconv"
	"time"

	httptransport "github.com/go-openapi/runtime/client"
	"github.com/go-openapi/strfmt"
	"github.com/openzipkin/zipkin-api-example/go/client"
	"github.com/openzipkin/zipkin-api-example/go/client/operations"
	"github.com/openzipkin/zipkin-api-example/go/models"
)

func main() {
	transport := httptransport.New("localhost:9411", "/api/v2", []string{"http"})
	zipkin := client.New(transport, strfmt.Default)

	id := uint64(rand.New(rand.NewSource(time.Now().UnixNano())).Int63())
	spanID := strconv.FormatUint(id, 16)
	timestamp := int64(time.Now().UnixNano() / int64(time.Microsecond))
	span := &models.Span{
		TraceID:   spanID,
		ID:        spanID,
		Kind:      models.SpanKindSERVER,
		Name:      "test",
		Timestamp: timestamp,
		Duration:  int64(200000),
		LocalEndpoint: &models.Endpoint{
			ServiceName: "testService",
			IPV4:        "192.228.233.62",
			Port:        80,
		},
		RemoteEndpoint: &models.Endpoint{
			IPV4: "192.228.233.62",
		},
		Tags: map[string]string{
			"http.path": "/api",
		},
	}

	resp, err := zipkin.Operations.PostSpans(
		operations.NewPostSpansParams().WithSpans(models.ListOfSpans{span}),
	)

	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(string(resp.Error()))
}

cc @kellabyte @basvanbeek

@codefromthecrypt
Copy link
Member Author

codefromthecrypt commented Aug 14, 2017

PS for those curious, we don't have a read api for this model, yet. the zipkin2 project will take more time to complete, but POST endpoints are available now (in latest 1.30). POST is more important as that's what tracers use. The read apis will come, but later.

Follow openzipkin/zipkin#1644 for updates

@codefromthecrypt
Copy link
Member Author

@flier @ellispritchard you might be interested in this, too

@codefromthecrypt
Copy link
Member Author

PS I will add more detailed descriptions here as I noticed I had to link people to java files

@codefromthecrypt
Copy link
Member Author

completed documentation

@codefromthecrypt
Copy link
Member Author

updated validation script and switched current link to v2

@codefromthecrypt
Copy link
Member Author

completed documentation

@ellispritchard
Copy link

Ta @adriancole !

@codefromthecrypt
Copy link
Member Author

@pavolloffay fyi I know you are working on json and v1 couldn't be code-genned. You may still prefer to not codegen v2, but anyway here's the model for it.

@pavolloffay
Copy link

@adriancole thanks for pointing to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants