Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Aug 15, 2017

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