-
Notifications
You must be signed in to change notification settings - Fork 308
Replace Temporality with Kind; Type with ValueType #168
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
Closed
Closed
Changes from 35 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
7dc68e8
Rough draft pre-comments
8838618
Comments and restoring order
907f253
Remove gen.go
01cdd17
metric_descriptor->descriptor
538e599
whitespace
5700d38
Define structure
58ecfab
Comments after @bogdandrutu and @MrAlias feedback
67f20c4
Revert data point changes, keep Kind & ValueType changes
e577247
Comment gen.go
50e0331
Checkpoint
0c3a7f6
Document each kind
c5f291a
Fix numbering
39e7967
One more #159 TODO
5e7fa7f
One more #159 TODO
88acc0c
Formatting
92ddee2
Undo generated files
82322a2
Upstream
e89503f
Remove go.mod
d870316
Comments
4a823d7
More comments on Kind
306d559
Format me
18271f2
Comments
d0186b0
Spelling
d081712
Grouping comment
20654a8
Asynchronous->Chronological
35bc2ba
Add missing comments
9d6210f
More comment on CHRONOLOGICAL
2855cec
More on CHRONOLOGICAL
9970a8b
Clarify ADDING|INSTANTANEOUS vs ADDING|DELTA
a551fb8
Clarify ADDING|INSTANTANEOUS vs ADDING|DELTA
ca17a32
Restore int64/double data points
bad082b
Restore int64/double data points
eeb489c
Make Monotonic a Structure
d0283cf
Generate code
ced5068
Upstream
fbcf615
Top of KindElement
376d80e
Rewrite KindElementdocs
bb9689f
Improve comments
15c7f92
Comment all Kind values
ab75b67
Merge 178
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| // Copyright 2020, OpenTelemetry Authors | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| // Notes: This code generates the Kind enum hex in metrics.proto. To | ||
| // run this code, execute: | ||
| // | ||
| // go run gen.go > out.go && go run out.go | ||
| // | ||
| // The output of this program MUST be tested in an external module, | ||
| // using the output of protoc. | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "fmt" | ||
| "go/format" | ||
| "os" | ||
| "strconv" | ||
| "strings" | ||
| ) | ||
|
|
||
| var ( | ||
| cumulativeProps = []string{"Instantaneous", "Delta", "Cumulative"} | ||
| structureProps = []string{"Adding_Monotonic", "Adding", "Grouping"} | ||
| syncProps = []string{"Continuous", "Snapshot"} | ||
| ) | ||
|
|
||
| func main() { | ||
| var buf bytes.Buffer | ||
| buf.WriteString(`package main | ||
|
|
||
| import "fmt" | ||
|
|
||
|
|
||
| type ( | ||
| Kind int | ||
| ) | ||
|
|
||
| const ( | ||
| INVALID = 0 | ||
|
|
||
| // One of the following three MUST be set. There are 3 exclusive Temporality kinds. | ||
| INSTANTANEOUS = 1 << 0 | ||
| DELTA = 2 << 0 | ||
| CUMULATIVE = 3 << 0 | ||
|
|
||
| // One of the following three MUST be set. There are 3 exclusive Structure kinds. | ||
| GROUPING = 1 << 2 | ||
| ADDING = 2 << 2 | ||
| ADDING_MONOTONIC = 3 << 2 | ||
|
|
||
| // May be set for any instrument. | ||
| SNAPSHOT = 1 << 4 | ||
| ) | ||
|
|
||
| var ( | ||
| `) | ||
| var fullnames []string | ||
| var fullvalues []string | ||
|
|
||
| for _, a := range structureProps { | ||
| for _, c := range cumulativeProps { | ||
| for _, s := range syncProps { | ||
| if c == "Instantaneous" && s == "Snapshot" { | ||
| continue | ||
| } | ||
| sfrag := "" | ||
| sname := "" | ||
| if s == "Snapshot" { | ||
| sfrag = "|SNAPSHOT" | ||
| sname = "_SNAPSHOT" | ||
| } | ||
| fullname := fmt.Sprint(strings.ToUpper(a), "_", strings.ToUpper(c), sname) | ||
| fullnames = append(fullnames, fullname) | ||
| fullvalue := fmt.Sprint("", strings.ToUpper(a), "|", strings.ToUpper(c), sfrag) | ||
| fullvalues = append(fullvalues, fullvalue) | ||
| buf.WriteString(fmt.Sprint(fullname, " Kind = ", fullvalue, "\n")) | ||
| } | ||
| } | ||
| } | ||
| buf.WriteString(`) | ||
|
|
||
| func main() { | ||
| `) | ||
|
|
||
| for i, fn := range fullnames { | ||
| buf.WriteString(fmt.Sprint(`fmt.Printf(" %s = %s; // %s\n", `, strconv.Quote(fn), ",", `fmt.Sprintf("%#x",`, fn, `)`, ",", strconv.Quote(fullvalues[i]), ")\n")) | ||
| } | ||
| buf.WriteRune('}') | ||
|
|
||
| src, err := format.Source(buf.Bytes()) | ||
| if err != nil { | ||
| fmt.Println("SOURCE WAS\n", string(buf.Bytes())) | ||
| panic(err) | ||
| } | ||
| if nwritten, err := os.Stdout.Write(src); err != nil || nwritten != len(src) { | ||
| panic(err) | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.